<style lang="less" scoped>
.panel {
  margin-bottom: 10px;
  &-title {
    display: flex;
    padding: 10px;
    border-bottom: 0.1px solid #eaeaea;
    background: white;

    &__label {
      flex: 1;
      font-size: 16px;
      align-items: center;
    }
  }
  &-content {
    margin-bottom: 10px;
    background: white;
    display: flex;

    &__dec {
      flex: 1;
    }
    &__arrow {
      display: flex;
      align-items: center;
    }
    &__item {
      display: flex;
      padding: 10px 10px 0 10px;
      font-size: 14px;
      &-label {
        color: #666;
      }
      &-value {
        flex: 1;
        padding-left: 15px;
        color: #333;
      }
    }
  }
}
</style>

<template>
  <div>
    <load v-if="loading"></load>
    <div v-else-if="items.length==0" class="info">暂无数据</div>
    <div class="panel" v-else>
      <template v-for="(item, index) in items" wx:key="unique">
        <!-- title -->
        <div class="panel-title" :key="'title'+index">
          <div class="panel-title__label" v-html="item.Name||'-'"></div>
          <div class="panel-title__right"></div>
        </div>
        <!-- content -->
        <div class="panel-content" :key="'content'+index" @click="itemClick(item)">
          <div class="panel-content__dec">
            <div class="panel-content__item">
              <div class="panel-content__item-label">证书编号</div>
              <div class="panel-content__item-value">{{item.No}}</div>
              <div class="panel-content__item-right"></div>
            </div>
            <div class="panel-content__item">
              <div class="panel-content__item-label">发证日期</div>
              <div class="panel-content__item-value">{{item.StartDate}}</div>
              <div class="panel-content__item-right"></div>
            </div>
            <div class="panel-content__item">
              <div class="panel-content__item-label">截止日期</div>
              <div class="panel-content__item-value">{{item.EndDate}}</div>
              <div class="panel-content__item-right"></div>
            </div>
          </div>
          <div class="panel-content__arrow">
            <i class="iconfont icon-more"></i>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>
<script>
import Load from '@/components/load';
export default {
  components: { Load },
  computed: {
    loading() {
      return this.$store.getters.loading;
    }
  },
  data() {
    return {
      items: [
        // {
        //   EndDate: '2022-08-29',
        //   Id: 'a9c6cc0771c79f19ae36523c4b618cf2_10',
        //   Name: '互联网药品信息',
        //   No: '(京)-经营性-2017-0020',
        //   StartDate: '2017-08-30',
        //   Type: 'C_997_42',
        //   TypeDesc: '互联网药品信息'
        // }
      ]
    };
  },
  onLoad() {
    this.getInfos();
  },
  methods: {
    async getInfos() {
      const url = '/xcx/getCertificationList';
      const params = {
        companyName: this.$route.query.searchKey,
        certCategory: this.$route.query.certCategory,
        pageIndex: 1
      };
      const res = await this.$http.get(url, params);
      if (res.status != 200) {
        wx.showToast({
          title: res.message || '获取失败！',
          icon: 'none',
          mask: true
        });
        return;
      }
      this.items = res.result.Result;
    },
    itemClick(item) {
      this.$router.push({
        path: '/pages/other/zhengshu/detail/main',
        query: { item: JSON.stringify(item) }
      });
    }
  }
};
</script>
